#ifndef CFpsController_h__
#define CFpsController_h__

#include "Header.h"
#include "CDevice.h"

#define  DEFAULT_LIMIT_FPS 25
namespace GameTutor
{
	class CFpsController
	{
	public:
		static CFpsController* GetInstance()
		{
			if (!s_pInstance)
			{
				s_pInstance = new CFpsController();
			}
			return s_pInstance;
		}
		virtual ~CFpsController() {}

		void SetLimitFrame(unsigned int limit);
		void BeginCounter();
		void EndCounter();

		__INT32 GetFrameDt() {return m_iFrameDt;}
		__INT32 GetRuntimeFps() {return (m_iFrameDt)?__INT32(1000/m_iFrameDt):0;}
		
	protected:
		CFpsController() : m_iFrameDt(0), m_iLimitFrameDt(0), m_iLimitFps(0), m_iStartTime(0)
		{
			SetLimitFrame(DEFAULT_LIMIT_FPS);
		}
		static CFpsController* s_pInstance;
	protected:
		int m_iLimitFps;
		int m_iLimitFrameDt;
		int m_iFrameDt;
	private:
		long m_iStartTime;
	};
}
#endif // CFpsController_h__
